package com.drp.controller;


import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.drp.bean.Client;
import com.drp.service.IClientService;
import com.drp.service.impl.ClientServiceImpl;
import com.drp.vo.ClientVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.RequestEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ren
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/client")
public class ClientController {
    @Autowired
    private IClientService clientService;
    @Autowired
    private ClientVO clientVO;
    @RequestMapping("/get")
    public ClientVO getAllClients(){
        List<Client> list = clientService.list();
        int count = clientService.count();
        clientVO.setData(list);
        clientVO.setCount(count);
        clientVO.setMsg("");
        clientVO.setCode(0);
        return clientVO;
    }

    @RequestMapping("/get/{id}")
    public ClientVO getClientVOById(@PathVariable("id") Integer id){
        Client byId = clientService.getById(id);
        List<Client> list = new ArrayList<>();
        list.add(byId);
        int count = clientService.count();
        clientVO.setData(list);
        clientVO.setCount(count);
        clientVO.setMsg("");
        clientVO.setCode(0);
        return clientVO;
    }


}
